﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="DodajKlienta.aspx.cs" Inherits="DentistOffice.DodajKlienta" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Dodaj nowego klienta</h2>

    <asp:EntityDataSource ID="Dklienta" runat="server" 
        ConnectionString="name=DentistEntities" DefaultContainerName="DentistEntities" 
        EnableFlattening="False" EnableInsert="True" EntitySetName="Patients">
    </asp:EntityDataSource>
    <form method="post" action="DodajKlienta.aspx">
    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" 
        AutoGenerateRows="False" DataKeyNames="id" DataSourceID="Dklienta" 
        DefaultMode = "Insert" CellPadding="4" ForeColor="#333333" GridLines="None" 
        onpageindexchanging="DetailsView1_PageIndexChanging" style="margin-right: 0px">
        <AlternatingRowStyle BackColor="White" />
        <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
        <EditRowStyle BackColor="#2461BF" />
        <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
        <Fields>
            <asp:TemplateField HeaderText="ID" SortExpression="id">
                <InsertItemTemplate>
                    <asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("id") %>'></asp:TextBox>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                     ControlToValidate="IDTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

              <asp:TemplateField HeaderText="Imię" SortExpression="Imię">
                <InsertItemTemplate>
                    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("name") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                     ControlToValidate="NameTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                     ControlToValidate = "NameTextBox"
                     ErrorMessage="Zacznij wielką literą."
                     ForeColor = "Red"
                     ValidationExpression="[A-Z][a-z]*"
                     Display="Dynamic"></asp:RegularExpressionValidator> 
                     
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="NLabel2" runat="server" Text='<%# Bind("name") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Nazwisko" SortExpression="Nazwisko">
                <InsertItemTemplate>
                    <asp:TextBox ID="SurnameTextBox" runat="server" Text='<%# Bind("surname") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
                     ControlToValidate="SurnameTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                     ControlToValidate = "SurnameTextBox"
                     ErrorMessage="Zacznij wielką literą."
                     ForeColor = "Red"
                     ValidationExpression="[A-Z][a-z]*"
                     Display="Dynamic"></asp:RegularExpressionValidator> 
                     <br />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("surname") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Telefon" SortExpression="Telefon">                
                <InsertItemTemplate>
                    <asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("phone") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                     ControlToValidate="PhoneTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                     ControlToValidate = "PhoneTextBox"
                     ErrorMessage="Podaj prawidłowy numer."
                     ForeColor = "Red"
                     ValidationExpression="[0-9]{9}"
                     Display="Dynamic"></asp:RegularExpressionValidator> 
                     <br />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("phone") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="email" SortExpression="email">
                <InsertItemTemplate>
                    <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("email") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                     ControlToValidate="EmailTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" 
                    ControlToValidate = "EmailTextBox"
                    ErrorMessage="Podaj prawidłowy email."
                    ForeColor = "Red"
                    ValidationExpression="^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$"
                    Display="Dynamic"></asp:RegularExpressionValidator> 
                    <br />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("email") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            
            <asp:TemplateField HeaderText="login" SortExpression="login">
                <InsertItemTemplate>
                    <asp:TextBox ID="LoginTextBox" runat="server" Text='<%# Bind("login") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
                     ControlToValidate="LoginTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("login") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Hasło" SortExpression="Hasło">
                <InsertItemTemplate>
                    <asp:TextBox ID="PasswordTextBox" runat="server" Text='<%# Bind("password") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
                     ControlToValidate="PasswordTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("password") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

            <asp:BoundField DataField="nip" HeaderText="nip" SortExpression="nip" />
            <asp:BoundField DataField="companyName" HeaderText="companyName" 
                SortExpression="companyName" />
            <asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
            <asp:BoundField DataField="street" HeaderText="street" 
                SortExpression="street" />
            <asp:BoundField DataField="cityCode" HeaderText="cityCode" 
                SortExpression="cityCode" />
            <asp:TemplateField HeaderText="idDentist" SortExpression="idDentist">
                <InsertItemTemplate>
                    <asp:TextBox ID="DentistIDTextBox" runat="server" Text='<%# Bind("idDentist") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
                     ControlToValidate="DentistIDTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("idDentist") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            
        </Fields>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
    </asp:DetailsView>
    </form>    
         <asp:Button ID="Button1" CssClass="but" runat="server" CausesValidation="true" CommandName="Insert" Text="Dodaj"    />
         <asp:Button ID="Button2" CssClass="but" runat="server" CausesValidation="false" CommandName="Cancel" Text="Anuluj" />
    
</asp:Content>
